﻿using System.Windows.Controls;
using System.Windows;
using System.Windows.Media;
using System.Linq;

namespace Test.Webcam
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void ChooseCameras()
        {
            if (CaptureDeviceConfiguration.AllowedDeviceAccess || CaptureDeviceConfiguration.RequestDeviceAccess())
            {
                if (CaptureDeviceConfiguration.GetAvailableVideoCaptureDevices().Count == 0)
                {
                    ErrorMessage.Visibility = System.Windows.Visibility.Visible;
                }
                else
                {
                    smf.CurrentPlaylistItem = smf.Playlist.FirstOrDefault();
                }
            }
            else
            {
                ErrorMessage.Visibility = System.Windows.Visibility.Visible;
            }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            StupidStartButton.Visibility = System.Windows.Visibility.Collapsed;
            ChooseCameras();
        }
    }
}
